package com.highstockings.dao;

import com.highstockings.model.Model;
import com.highstockings.model.ModelVo;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("ModelMapper")
public interface ModelMapper {
    int deleteByPrimaryKey(Integer mid);

    int insert(Model record);

    int insertSelective(Model record);

    Model selectByPrimaryKey(Integer mid);

    int updateByPrimaryKeySelective(Model record);

    int updateByPrimaryKey(Model record);

    @Select("select * from tb_model order by mid desc")
    List<Model> selectAllModel();

    @Select("select * from tb_model where mid!=0 order by mid desc")
    List<ModelVo> selectAllModelVo();

    @Select("select mid,realname,alias,piclink,rank,modellabel from tb_model where mid!=0 order by picsnumber desc limit 5")
    List<ModelVo> selectRecentModel();

    @Select("select * from tb_model where mid!=0 and alias like concat(concat('%',#{alias}),'%')")
    Model selectByAlias(String alias);

    @Select("select mid,realname,alias,piclink,measurements,rank,modellabel from tb_model where mid!=0 order by rank desc limit 5")
    List<Model> selectTop5Model();

    @Select("select * from tb_model where mid!=0 and modellabel like concat(concat('%',#{label}),'%')")
    List<ModelVo> selectModelByLabel(String label);

    /**
     * 增加模特人气
     *
     * @return
     */
    @Update("update tb_model set picsnumber=picsnumber+1 where mid=#{mid}")
    int updateBuzz(int mid);
}

